package main

func main() {
	var cityNames map[string]string     //声明map类型, 此时是nil
	cityNames = make(map[string]string) //初始化map, 相当于new

	cityNames["China"] = "中国"
	cityNames["Japan"] = "日本"

	for key := range cityNames {
		println(key, cityNames[key])
	}

	// name接收key对应的value, ok是否存在，true是，false否
	name, ok := cityNames["China"] // 判断是否存在某个key
	println(name, ok)

	peoples := map[string]string{"tom": "China", "cat": "Amercia"}

	for k := range peoples {
		println(k, peoples[k])
	}
	delete(peoples, "tom") // 删除key为tom对应的值

	for k := range peoples {
		println(k, peoples[k])
	}

	for k, v := range peoples {
		println(k, v)
	}

}
